/*
 * llc_timer.c
 *
 *  Created on: Apr 22, 2013
 *      Author: ILYA
 */
#include "llc_timer.h"
#include "Mutex.h"

void llc_init_base_timers()
{

}

void llc_sim_timer(unsigned long sim_time_duration)
{
	static Timer_Tik last_sim_time = 0;
	if(is_sim_time)
	{
		last_sim_time = TC1_Get_us();
		is_sim_time = 0;
	}
	if(TC1_Get_us() - last_sim_time > sim_time_duration)
	{
		last_sim_time = TC1_Get_us();
		is_sim_time = 1;
	}
}

Timer_Tik last_rim_time = 0;
void llc_start_rim_timer(void)
{
	is_rim_time = 0;
	last_rim_time = TC1_Get_us();
}

void llc_rim_timer(unsigned long rim_time_duration)
{
	is_rim_time = 0;
	if(TC1_Get_us() - last_rim_time > rim_time_duration)
	{
		//last_rim_time = TC1_Get_us();
		is_rim_time = 1;
	}
}

void llc_response_timer_expiry(unsigned long response_time_duration)
{
	static Timer_Tik last_response_time = 0;
	if(is_response_time_expire)
	{
		last_response_time = TC1_Get_us();
		is_response_time_expire = 0;
	}
	if(TC1_Get_us() - last_response_time > response_time_duration)
	{
		last_response_time = TC1_Get_us();
		is_response_time_expire = 1;
	}
}
